#pragma once
#include <map>
#include "vmsg_meta.h"
#include "unique_instance.h"

class vtps
{
    public:
        UNIQUE_INSTANCE(vtps);

    public:
        virtual ~vtps();
    private:
        vtps();

    public:
        unsigned long long tps(const std::string & name);

        //for tps, such as how many transactions percent second
        void increase(const std::string & name, 
                bool auto_log = false,
                unsigned int interval = 0); //unit:ms

        //for tps, such as how many bytes percent second
        void increase(unsigned long long byte_count,
                const std::string & name, 
                bool auto_log = false,
                unsigned int interval = 0); //unit:ms


        void clear(const std::string & name);
        void clear();


    protected:
        std::map<std::string, vmsg_meta> _map_name_msg;
        std::mutex _mutex;
};



